﻿// Copyright (c) Vitaly Kamiansky. All rights reserved. 
// See License.txt in the project root.

using System;

namespace Property.Workers
{
    public partial class CatchFunctionWorkerDecoratorPrototype<T> : FunctionWorkerDecoratorPrototype<T>, IFunctionWorkerPrototype<T>
    {
        public CatchFunctionWorkerDecoratorPrototype(IFunctionWorkerPrototype<T> compositionBasePrototype, Action<Exception> handler)
            : base(compositionBasePrototype)
        {
            _Handler = handler;
        }

        //=//

        private readonly Action<Exception> _Handler;

        public override IWorker Create(Func<T> getValue)
        {
            return new DecoratorInstance(_CompositionBasePrototype, getValue, _Handler);
        }
    }
}
